/**
 * 
 */
package com.ternnetwork.core.entity.org;

import java.io.Serializable;
import java.util.Date;


import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.TableGenerator;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Transient;
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.ternnetwork.commons.utils.JsonUtils;
import com.ternnetwork.commons.utils.JsonDateSerializer;




/**
 * 
 * @author xuwenfeng
 *
 */
@Entity
@Table(name="VS_ORG")
@JsonAutoDetect
@JsonIgnoreProperties(value={"users"})
public class Organization implements Serializable {
	
	
	
	/**
	 * 
	 */
	private static final long serialVersionUID = -9081562278162665226L;

	@Id@Column(name="ID",nullable=false)
	@GeneratedValue(strategy = GenerationType.TABLE,generator="id_gen")
    @TableGenerator(name = "id_gen",pkColumnValue="ORGANIZATION_ID",table="VS_ID_GENERATOR", pkColumnName="GEN_NAME",valueColumnName="GEN_VALUE",allocationSize=1)
	private long id;
	
	@Column(name="NAME",nullable=false,length=200)
	private String name;//名称
	
	
	@Column(name="PARENT_ID",nullable=false)
	private Long parentId=0L;//父节点点ID
	
	
	@Column(name="SEQ_NUM",nullable=false)
	private Integer seqNum=0;//排序
	
	
	@Column(name="CODE",unique=true)
	private String code;//代码
	
	
	@Column(name="ADDRESS")
	private String address;//地址
	
	@Column(name="TELEPHONE")
	private String telephone;//电话
	
	
	@Column(name="EMAIL")
	private String email;//邮箱
	
	
	@Column(name="CONTACT_PERSON")
	private String contactPerson;//联系人
	
	@Temporal(TemporalType.TIMESTAMP)@Column(nullable=false,name="CREATE_TIME")
	private Date createTime=new Date();
	
	
	@Temporal(TemporalType.TIMESTAMP)@Column(nullable=false,name="UPDATE_TIME")
	private Date updateTime=new Date();
	
	@Transient
	private String parentName;
	
	@Transient
	private String parentCode;

	public long getId() {
		return id;
	}
	public void setId(long id) {
		this.id = id;
	}
	
	
	public Long getParentId() {
		return parentId;
	}
	public void setParentId(Long parentId) {
		this.parentId = parentId;
	}
	public Integer getSeqNum() {
		return seqNum;
	}
	public void setSeqNum(Integer seqNum) {
		this.seqNum = seqNum;
	}
	@JsonSerialize(using=JsonDateSerializer.class)
	public Date getCreateTime() {
		return createTime;
	}
	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}
	
	@JsonSerialize(using=JsonDateSerializer.class)
	
	public Date getUpdateTime() {
		return updateTime;
	}
	public void setUpdateTime(Date updateTime) {
		this.updateTime = updateTime;
	}
	


	
	
    @Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + (int) (id ^ (id >>> 32));
		return result;
	}
    @Override
	public boolean equals(Object obj) {
		if (this == obj){
			return true;
		}
		if (obj == null){
			return false;
		}
		if (getClass() != obj.getClass()){
			return false;
		}
		Organization other = (Organization) obj;
		if (id != other.id){
			return false;
		}
		return true;
	}
	public Organization(String name, String nameEn, long parentId,
			Integer seqNum) {
		super();
		this.name = name;
		this.parentId = parentId;
		this.seqNum = seqNum;
		
	}
	public Organization() {
		super();
	}
	@Override
	public String toString() {
		return JsonUtils.objectToJson(this);
	}
	

	public String getCode() {
		return code;
	}
	public void setCode(String code) {
		this.code = code;
	}
	public String getAddress() {
		return address;
	}
	public void setAddress(String address) {
		this.address = address;
	}
	public String getTelephone() {
		return telephone;
	}
	public void setTelephone(String telephone) {
		this.telephone = telephone;
	}
	public String getEmail() {
		return email;
	}
	public void setEmail(String email) {
		this.email = email;
	}
	public String getContactPerson() {
		return contactPerson;
	}
	public void setContactPerson(String contactPerson) {
		this.contactPerson = contactPerson;
	}
	public String getParentName() {
		return parentName;
	}
	public void setParentName(String parentName) {
		this.parentName = parentName;
	}
	public String getParentCode() {
		return parentCode;
	}
	public void setParentCode(String parentCode) {
		this.parentCode = parentCode;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	
	
	
	
	
	

}
